﻿using System.Collections.Generic;
using TestBat.IModels.Domain;

namespace TestBat.IModels.Models
{
    public interface ITaskFolderModel : IModel
    {
        /// <summary>
        /// save/persist a task-folder
        /// </summary>
        /// <param name="taskFolder">the task-folder to persist</param>
        void Save(ITaskFolder taskFolder);

        /// <summary>
        /// remove the task-folder from the DB
        /// </summary>
        /// <param name="taskFolder">the task-folder to remove</param>
        void Delete(ITaskFolder taskFolder);

        /// <summary>
        /// revert the task-folder to DB state
        /// </summary>
        /// <param name="taskFolder">the task folder to revert</param>
        void Revert(ITaskFolder taskFolder);

        /// <summary>
        /// get the folder with no parent (if there's more than one, get the first)
        /// </summary>
        /// <returns>the folder not having a parent</returns>
        IRootTaskFolder GetRootFolder();

        /// <summary>
        /// create a subfolder inside the parent folder
        /// </summary>
        /// <param name="parent">the parent folder</param>
        ILeafTaskFolder CreateSubfolder(ITaskFolder parent);

        /// <summary>
        /// create a new task
        /// </summary>
        /// <typeparam name="T">the task-type to create</typeparam>
        /// <param name="taskFolder">the parent-folder</param>
        /// <returns>a new persistent task</returns>
        T CreateTask<T>(ITaskFolder taskFolder) where T : ITask;

        /// <summary>
        /// get all children of the specified parent folder
        /// </summary>
        /// <param name="parent">the parent folder</param>
        /// <returns>a list of leaftaskfolders</returns>
        IList<ILeafTaskFolder> GetChildren(ITaskFolder parent);

        /// <summary>
        /// get all tasks inside this folder
        /// </summary>
        /// <param name="taskFolder">the task folder</param>
        /// <returns>all tasks inside the folder</returns>
        IList<ITask> GetTasks(ITaskFolder taskFolder);

        /// <summary>
        /// get the number of tasks in the folder
        /// </summary>
        /// <param name="taskFolder">the folder to get count for</param>
        /// <returns>the number of tasks</returns>
        int GetTaskCount(ITaskFolder taskFolder);
    }
}
